package com.sky.controller.admin;

import com.sky.constant.RedisConstant;
import com.sky.result.Result;
import com.sky.service.admin.ShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.awt.*;

/**
 * @Description ShopController
 * @Author zhengyuan&junjun
 * @Date 2024-10-12
 */
@RestController
@RequestMapping("/admin/shop")
@ApiOperation("店铺相关接口")
public class ShopController {

    @Autowired
    private ShopService shopService;
    @Autowired
    private RedisTemplate redisTemplate;


    @PutMapping ("/{status}")
    @ApiOperation("设置店铺状态")
    public Result<String> setshopStatus(@PathVariable("status") Integer status ){

        redisTemplate.opsForValue().set(RedisConstant.SHOP_STATUS_KEY,status);







        return  Result.success();



    }
     @GetMapping("/status")
     @ApiOperation("获取店铺的营业状态")
      public  Result<Integer> getStatus(){

       Integer status = (Integer) redisTemplate.opsForValue().get(RedisConstant.SHOP_STATUS_KEY);

        if (status == null){
           //初始化值
            status = 0;
        }
        return  Result.success(status);
      }

}
